// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//

const cypress = require('cypress');

// -- This is a parent command --
Cypress.Commands.add("login", (account, password) => {
    cy.visit('/Account/LogIn?s=exp');
    
    cy.get('#Account').type(account);
    cy.get('#Password').type(password);
    cy.get('#hfViewUserId').invoke('val', 'dc\\vr_zhangfenglin');

    cy.get('#frmLogOn').submit();
});

Cypress.Commands.add('logout', () => {
    cy.get('#frmLogOff').invoke('trigger', 'click');
    cy.get('.layui-layer-dialog .layui-layer-btn0').invoke('trigger', 'click');
});

//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//

// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

require('./commands.menus');

beforeEach(() => {
    // 解决cookie共享的问题。
    Cypress.Cookies.preserveOnce('.iWorkflow.Auth');
});